#include "GUIWindow.h"

namespace Aurora
{
	GUIWindow::GUIWindow()
		:	_parent(0), _name("Anonymous"), _visible(true)
	{

	}

	GUIWindow::~GUIWindow()
	{

	}

	void GUIWindow::render()
	{
		renderSelf();

		//
		Children::iterator it;
		for (it = _children.begin(); it != _children.end(); ++it)
		{
			it->second->render();
		}
	}

	void GUIWindow::renderSelf()
	{
		
	}

	void GUIWindow::addChild( GUIWindow* child )
	{
		if (!child)
		{
			return;
		}

		Children::iterator it = _children.find(child->getName());
		if (it != _children.end())
		{
			return;
		}

		//
		child->setParent(this);

		//
		_children[child->getName()] = child;
	}

	void GUIWindow::setParent( GUIWindow* parent )
	{
		if (!parent)
		{
			return;
		}

		//
		_parent = parent;
	}

	std::string GUIWindow::getName()
	{
		return _name;
	}

	void GUIWindow::removeChild( std::string name )
	{
		Children::iterator it = _children.find(name);

		//
		if (it == _children.end())
		{
			return;
		}

		//
		it->second->setParent(NULL);
		_children.erase(name);
	}

	bool GUIWindow::isVisible()
	{
		return _visible;
	}

	void GUIWindow::setVisible( bool visible )
	{
		_visible = visible;
	}
}